package com.tech.cloudapp.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tech.cloudapp.biz.service.IBQuestionUserAllService;
import com.tech.cloudapp.db.entity.QuestionUserAll;
import com.tech.cloudapp.db.service.QuestionUserAllService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Primary
@Service
public class BQuestionUserAllServiceImpl implements IBQuestionUserAllService {

    @Autowired
    private QuestionUserAllService questionUserAllServiceImpl;

    @Override
    public List<QuestionUserAll> questionUserAllList(QuestionUserAll questionUser) {
        QueryWrapper<QuestionUserAll> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",questionUser.getUserId());
        queryWrapper.eq("is_done",1);
        if(questionUser.getPaperId() != null && questionUser.getPaperId() > 0 )
        {
            queryWrapper.eq("paper_id",questionUser.getPaperId());
        }
        List<QuestionUserAll> list = questionUserAllServiceImpl.list(queryWrapper);

        if(list == null)
        {
            list = new ArrayList();
        }
        return list;
    }
}
